package DINO;

import java.sql.*;
import java.util.Properties;

class Baza {
    
    private Connection connect;

    Baza() {
        connect = openConnection();	
    }
    
    public Connection openConnection() throws Exception {
        try {
            String url = "jdbc:mysql://localhost:3306/testdb adres do bazy razem ze sterownikiem";
            String user = "uzytkownik";
            String password = "haslo";
            connect = DriverManager.getConnection(url, user, password);
        } catch (Exception e) {
            throw e;
        }
        return connect;
    }
    
    public Connection getConnection() { return connect; }
    
    public ResultSet getExercises(String TYP, String DZIAL, String POZIOM) throws Exception {
        
        PreparedStatement statement = connection.prepareStatement("SELECT * FROM zadania.ZADANIA WHERE TYP = ? AND DZIAL = ? AND POZIOM = ?");
        statement.setString(1, TYP);
        statement.setString(2, DZIAL);
        statement.setString(3, POZIOM);
        
        return statement.executeQuery(query);
    }
    
    public void putExercise() {
    
    }
}
